﻿//05.You are given a text. Write a program that changes the text in all regions surrounded by the tags <upcase> and </upcase> to uppercase. The tags cannot be nested.
//Example: We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.
//The expected result: We are living in a YELLOW SUBMARINE. We don't have ANYTHING else.

using System;
using System.Text;


namespace ChangeToUpperCase
{
    class ChangeToUpperCase
    {
        static void Main()
        {
            string replaceStart = "<upcase>";
            string replaceEnd = "</upcase>";
            string text = "We are living in a <upcase>yellow submarine</upcase>. We don't have <upcase>anything</upcase> else.";

            Console.WriteLine(ChangeToUpper(text, replaceStart, replaceEnd));

        }

        private static string ChangeToUpper(string text, string replaceStart, string replaceEnd)
        {
            while (text.IndexOf(replaceStart) != -1)
        {
            int startPosition = text.IndexOf(replaceStart);
            int endPosition = text.IndexOf(replaceEnd);
            string temp = text.Substring(startPosition + replaceStart.Length, endPosition - startPosition - replaceStart.Length);
            text = text.Replace(replaceStart + temp + replaceEnd, temp.ToUpper());
        }
        return text;
        }
    }
}
